import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(-5, 5, 401)
yt = []
for t in x:
    yx = 1 / (1 + t * t)
    yt.append(yx)

plt.figure()
filename = "data/ProC.txt"
with open(filename, 'r') as f:
    lines = f.readlines()

y1 = [float(s) for s in lines[0].split()]
y2 = [float(s) for s in lines[1].split()]

plt.plot(x, yt, label = "y = f(x)")
plt.plot(x, y1, label = "y = s(x),S32", linestyle = "--")
plt.plot(x, y2, label = "y = s(x),S21", linestyle = "--")
plt.xlabel("x")
plt.ylabel("y")
plt.title("Use ppForm to interpolate f(x) with different knots.")
plt.legend()

figurename = "../report/figure/ProC.png"
plt.savefig(figurename)
print("Finish ploting for Pro C.")